% !TEX root = base-r.tex

\begin{block}{Types}
  \vspace{1ex}
  
  \centering
  \begin{minipage}{0.8\linewidth}
    \centering
    Converting between common data types in R. Can always go from a higher value in the table to a lower value.
  \end{minipage}
  
  \vspace{1ex}
  
  \small\renewcommand{\arraystretch}{1.3}
  \begin{tableau}{>{\color{black}}l | >{\color{darkgray}}m{0.31\linewidth} | >{\color{black}\centering\arraybackslash}m{0.35\linewidth}}
    \inl{as.logical} & \inl{TRUE, FALSE, TRUE} & Boolean values (TRUE or FALSE)\\
    \inl{as.numeric} & \inl{1, 0, 1} & Integer or floating point numbers\\
    \inl{as.character} & \inl{'1', '0', '1'} & Character strings. Generally preferred to factors\\
    \inl{as.factor} & \inl{'1', '0', '1'}\qquad\inl{levels: '1', '0'}  & Character strings with preset  levels. Needed for some statistical models\\
  \end{tableau}
  
\end{block}

{\setbeamercolor{block body}{fg = black, bg = white}
\begin{block}{Maths Functions}
  \small\renewcommand{\arraystretch}{1.3}
  \begin{tabular}{r m{0.25\linewidth} r m{0.25\linewidth}}
    \inl{log(x)} & Natural log. & \inl{sum(x)} & Sum.\\
    \inl{exp(x)} & Exponential. & \inl{mean(x)} & Mean.\\
    \inl{max(x)} & Largest element. & \inl{median(x)} & Median.\\
    \inl{min(x)} & Smallest element. & \inl{quantile(x)} & Percentage quantiles.\\
    \inl{(x, n)} & Round to n decimal places. & \inl{rank(x)} & Rank of elements.\\
    \inl{(x, n)} & Round to n significant figures. & \inl{var(x)} & The variance.\\
    \inl{(x, y)} & Correlation. & \inl{sd(x)} & The standard deviation.
  \end{tabular}
\end{block}
}

\begin{block}{Variable Assignment}
  \begin{code}
    \begin{Pseudo}
 > a <- 'apple'
 > a
 [1] 'apple'
    \end{Pseudo}
  \end{code}
\end{block}

\begin{block}{The Environment}
  \renewcommand{\arraystretch}{1.3}
  \begin{tabular}{l m{0.6\linewidth}}
    \inline{ls()} & List all variables in the environment.\\
    \inline{rm(x)} & Remove x from the environment.\\
    \inline{rm(list = ls())} & Remove all variables from the environment.
  \end{tabular}
  
  \vspace{1ex}
  
  \centering
  \begin{minipage}{0.8\linewidth}
    \centering
    \textbf{You can use the environment panel in RStudio to browse variables in your environment.}
  \end{minipage}
\end{block}
